package com.zycfc.zsf.boot.web.autoconfigure;

import org.springframework.boot.autoconfigure.condition.*;
import javax.servlet.*;
import com.zycfc.zsf.boot.redis.*;
import org.springframework.beans.factory.annotation.*;
import com.zycfc.zsf.boot.web.filter.*;
import org.springframework.context.annotation.*;
import org.slf4j.*;

@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass({ Filter.class })
public class GenericFilterAutoConfig
{
    private static final Logger log;
    @Value("${spring.profiles.active:local}")
    private String profilesActive;
    @Value("${spring.application.name:default}")
    private String applicationName;
    @Autowired
    private IRedisOperater redisOperater;
    
    @Bean
    HttpResponseInjectingTraceFilter responseInjectingTraceFilter() {
        final String prodEnv = "prod";
        final boolean notProdEnv = !prodEnv.equals(this.profilesActive);
        GenericFilterAutoConfig.log.info("^_^applicationName:{},profilesActive:{},notProdEnv:{}", new Object[] { this.applicationName, this.profilesActive, notProdEnv });
        return new HttpResponseInjectingTraceFilter(notProdEnv, this.redisOperater);
    }
    
    static {
        log = LoggerFactory.getLogger((Class)GenericFilterAutoConfig.class);
    }
}
